﻿using MongoDB.Bson.Serialization.Attributes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Model
{
    public abstract class BattleEventComponent : ComponentDB
    {
        [BsonIgnore]
        public abstract BattleEventType[] EventType { get; set; }
        [BsonIgnore]
        public virtual int SortIndex { get; set; } = 5;
        [BsonIgnore]
        public virtual bool IfTrap { get; set; } = false;
        public void Awake()
        {
            foreach (var type in EventType)
                Game.Scene.GetComponent<BattleEventWatcherComponent>().AddEvent(type, this);
        }
        public abstract Task RunEvent(BattleEventType eventType,FightModel fightModel, params object[] param);

        public override void Dispose()
        {
            foreach (var type in EventType)
                Game.Scene.GetComponent<BattleEventWatcherComponent>().RemoveEvent(type, this);//Dispose时取消注册的事件
            base.Dispose();
        }
    }
}
